#include <Comm.h>


void print_status() {
  Serial.println("");
  Serial.print("RECV_START "); Serial.println(RECV_START);
  Serial.print("RECEIVING ");  Serial.println(RECEIVING);
  Serial.print("RECV_DONE "); Serial.println(RECV_DONE);
  Serial.print("ERR_UNKNOWN "); Serial.println(ERR_UNKNOWN);
  Serial.print("ERR_OVERFLOW "); Serial.println(ERR_OVERFLOW);
  Serial.println("");
}

DataFrame df;


void print_df(DataFrame *df);  // 
void print_df(DataFrame *df) {
  Serial.print("buf_size "); Serial.println(df->buf_size);
  Serial.print("frame_size "); Serial.println(df->frame_size);
  Serial.print("received "); Serial.println(df->received);
  Serial.print("buffer "); Serial.write(df->buf, df->buf_size);
}


void test_Init_Feed() {
  DataFrame df;
  byte df_buffer[10];
  DF_Init(&df, df_buffer, 5, 5);

  while (true) {
    if (Serial.available()) {
      int ch = Serial.read();
      status_t ret = DF_Feed(&df, ch);
      
      Serial.println();
      Serial.println();
      Serial.print("ret "); Serial.println(ret);
      print_df(&df);
    }
  }
}

void test_DataFrame() {
  print_status();
  test_Init_Feed();
}
